/**
* Copyright @ 2023 iAuto (Shanghai) Co., Ltd.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are NOT permitted except as agreed by
* iAuto (Shanghai) Co., Ltd.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/

import React from 'react'
import classNames from 'classnames'

import styles from './index.less'
import { isFunction } from 'lodash'

interface IIdeButton {
    disabled?: boolean
    [extraProps: string]: any
}
const IdeButton: React.FC<IIdeButton> = (props) => {
    const { icon, children, onClick, disabled = false, className, ...extraProps } = props;

    return (
        <div className={classNames(disabled ? styles.disabled : '', styles.btn, className)} onClick={() => {
            if (disabled) {
                return;
            }

            if (isFunction(onClick)) {
                onClick();
            }
        }} {...extraProps}>{icon}{children}</div>
    )
}

export default IdeButton